<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <%@include file="/WEB-INF/jspf/meta/meta.jspf" %>
    <title>Title</title>
    <%@include file="/WEB-INF/jspf/adminPage.jspf" %>
    <script type="text/javascript" src="<%=request.getContextPath()%>/static/_framework/jquery/jquery.serializejson.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/static/_framework/jquery/date.js"></script>
    <script src="<%=request.getContextPath()%>/static/_framework/Highcharts/code/highcharts.js"></script>
    <script src="<%=request.getContextPath()%>/static/_framework/Highcharts/code/modules/exporting.js"></script>
    <script src="<%=request.getContextPath()%>/static/_framework/Highcharts/code/modules/export-data.js"></script>
</head>
<script>
$(function () {
    $.ajax({
        url:path_home+'/statistics/pie',
        type:'get',
        dataType:'json',
        success:function(data){
            showChart(data);
        }
    })

    $.ajax({
        url:path_home+'/statistics/column',
        type:'get',
        dataType:'json',
        success:function(data){
            showChart2(data);
        }
    })

})

function showChart2(_data){
    Highcharts.chart('container', {
        chart: {
            type: 'column'
        },
        title: {
            text: '最近一年招生数量统计'
        },
        subtitle: {
            text: '按月份划分'
        },
        xAxis: {
            type: 'category'
        },
        yAxis: {
            min: 0,
            title: {
                text: 'Rainfall (mm)'
            }
        },
        tooltip: {
            headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
            pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
                '<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
            footerFormat: '</table>',
            shared: true,
            useHTML: true
        },
        plotOptions: {
            column: {
                pointPadding: 0.2,
                borderWidth: 0
            }
        },
        series: [{
            name: '月份',
            data: _data,
        }]
    });

}


function showChart(_data) {

    Highcharts.chart('pieChart', {
        chart: {
            plotBackgroundColor: null,
            plotBorderWidth: null,
            plotShadow: false,
            type: 'pie'
        },
        title: {
            text: '最近一月招生情况'
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        credits:{
            //去除右下角版权信息
            enabled:false
        },
        plotOptions: {
            pie: {
                allowPointSelect: true,
                cursor: 'pointer',
                dataLabels: {
                    enabled: false
                },
                showInLegend: true
            }
        },
        series: [{
            name: '比例',
            colorByPoint: true,
            data: _data
        }]
    });
}
</script>
<body>
    <body class="easyui-layout">
        <div data-options="region:'center',title:'招生统计'" style="padding:5px;">
            <div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
        </div>
        <div data-options="region:'east',title:'统计图表',split:true" style="width:30%;padding:5px;">
            <div id="pieChart" style="min-width: 310px; height: 400px; max-width: 600px; margin: 0 auto"></div>
        </div>
    </body>
</body>
</html>